#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	int t;
	int line[101];
	int rank[101];
	scanf("%d",&t);
	while(t--)
	{
		int numL,numR,ans;
		numL = numR = 0;
		memset(line,0,sizeof(line));
		memset(rank,0,sizeof(rank));
		int n,m,k;
		scanf("%d %d %d",&n,&m,&k);
		int x,y;
		while(k--)
		{
			scanf("%d %d",&x,&y);
			line[x] = 1;
			rank[y] = 1;
		}
		for(int i = 1;i<=n;i++) if(!line[i]) numL++;
		for(int i = 1;i<=m;i++) if(!rank[i]) numR++;
		ans = numL*m+numR*n-numL*numR;
		printf("%d\n",ans);
	}
}
